import javax.swing.*;
import java.awt.*;

public class MonteurFenetre {
    JFrame fenetre;
    JPanel centre;
    JPanel bas;

    public MonteurFenetre() {
	// preparation panneau centre
	centre = new JPanel();
	centre.setLayout(new BoxLayout(centre, BoxLayout.LINE_AXIS));
	centre.add(Box.createHorizontalGlue());
	centre.add(Box.createRigidArea(new Dimension(10, 0)));

	// preparation panneau bas
	bas = new JPanel();
	bas.setLayout(new BoxLayout(bas, BoxLayout.LINE_AXIS));
	bas.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
	bas.add(Box.createHorizontalGlue());
    }

    public void ajout(JComponent jComponent) {
	centre.add(jComponent);
	centre.add(Box.createRigidArea(new Dimension(10, 0)));
    }

    public void ajoutBas(JComponent jComponent) {
	bas.add(jComponent);
	bas.add(Box.createRigidArea(new Dimension(10, 0)));
    }

    public JFrame retourneFenetre() {
	if (fenetre != null)
	    return fenetre;

	fenetre = new JFrame();
	// operation de fermeture
	fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	// ajout des panneaux centre et bas
	Container contentPane = fenetre.getContentPane();
	contentPane.add(centre,BorderLayout.CENTER);
	contentPane.add(bas,BorderLayout.SOUTH);

	// formater et rendre visible
	fenetre.pack();
	fenetre.setVisible(true);
	return fenetre;
    }
}